package vn.edu.ptithcm.pim.dao;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import vn.edu.ptithcm.pim.dom.Application;

@SuppressWarnings("rawtypes")
public class ApplicationDao extends HibernateDaoSupport {

	public void save(Application application) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().save(application);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void saveOrUpdate(Application application) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().saveOrUpdate(application);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void lock(Application application) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().lock(application, LockMode.NONE);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(Application application) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().delete(application);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Application merge(Application application) {
		try {
			return (Application) getHibernateTemplate().merge(application);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Application findById(java.lang.Long id) {
		try {
			return (Application) getHibernateTemplate().get(Application.class,
					id);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List findByExample(Application application) {
		try {
			return getHibernateTemplate().findByExample("Application",
					application);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List getAll() {
		try {
			return getHibernateTemplate().loadAll(Application.class);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}
